/* ----------------------------------------------------------------------
*
* Copyright (C) 2025 XiaoFei. All rights reserved.
*
* $file:		XiaoZhi_TCRT5000.h
* $Date:        26-January-2025
* $Revision: 	V1
* $Project: 	XiaoFei BSP Library
* $Taobao:      https://item.taobao.com/item.htm?abbucket=17&id=795736071271
*
* -------------------------------------------------------------------- */

#ifndef __XiaoZhi_TCRT5000_H
#define __XiaoZhi_TCRT5000_H

#define TCRT5000_Use_ADC1

#if defined(TCRT5000_Use_ADC2)||defined(TCRT5000_Use_ADC1)
    #define TCRT5000_RCC_AO				RCC_APB2Periph_GPIOA
    #define TCRT5000_GPIO_AO			GPIOA
    #define TCRT5000_PIN_AO				GPIO_Pin_1
    #define TCRT5000_ADC_Channel		ADC_Channel_1
#endif

#ifdef TCRT5000_Use_DO
    #define TCRT5000_RCC_DO				RCC_APB2Periph_GPIOA
    #define TCRT5000_GPIO_DO			GPIOA
    #define TCRT5000_PIN_DO				GPIO_Pin_1
    #define TCRT5000_Trigger			Bit_RESET
#endif

/* 
* @function: 	TCRT5000_Init
*/
void TCRT5000_Init(void);

#if defined(TCRT5000_Use_ADC2)||defined(TCRT5000_Use_ADC1)
/* 
* @function: 	TCRT5000_GetValue
* @return:		The ADC value from TCRT5000. This value will be mapped from 0 to 3.3 volts to 0 to 4096.
*/
unsigned int TCRT5000_GetValue(void);
#endif

#if defined(TCRT5000_Use_ADC2)||defined(TCRT5000_Use_ADC1)
/* 
* @function: 	TCRT5000_GetVoltage
* @return:		The Voltage value from TCRT5000. This value need to be limited to 0 to 3.3 volts.
*/
float TCRT5000_GetVoltage(void);
#endif

#ifdef TCRT5000_Use_DO
/* 
* @function: 	TCRT5000_IsTrigger
* @return:		Return 0x01 if the TCRT5000 is trigger.
*/
unsigned char TCRT5000_IsTrigger(void);
#endif

#endif


